package com.heima.admin.controller.v1;

import com.heima.admin.service.AdUserService;
import com.heima.apis.admin.LoginControllerApi;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.common.dtos.AdUserDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Jt
 * @date 2021/4/11 16:34
 */
@RestController
@RequestMapping("/login")
public class LoginController implements LoginControllerApi {

    @Resource
    private AdUserService adUserService;

    /**
     * admin登录
     * @param adUserDto
     * @return
     */
    @PostMapping("/in")
    @Override
    public ResponseResult login(@RequestBody AdUserDto adUserDto) {
        return adUserService.login(adUserDto);
    }

    /**
     * 注册功能
     * @param adUser
     * @return
     */
    @PostMapping("/register")
    @Override
    public ResponseResult register(@RequestBody AdUser adUser) {
        return adUserService.register(adUser);
    }
}
